package pl.edu.agh.anomalyids.lerad.rule.util;

import java.util.List;

import pl.edu.agh.anomalyids.network.Packet;

public class PacketsDivider {
	
	private List<Packet> packets;
	private int sampleSetEnd;
	private int validationSetEnd;
	private int trainingSetEnd;
	
	public PacketsDivider(List<Packet> packets) {
		super();
		this.packets = packets;
		
		dividePackets();
	}

	public List<Packet> getSampleSetList() {
		return packets.subList(0, sampleSetEnd);
	}
	
	public List<Packet> getValidationSetList() {
		return packets.subList(trainingSetEnd + 1, validationSetEnd);
	}
	
	public List<Packet> getTrainingSetList() {
		return packets.subList(sampleSetEnd + 1, trainingSetEnd);
	}
	
	private void dividePackets() {
		sampleSetEnd = (int) (packets.size() * 0.15);
		trainingSetEnd = (int) (packets.size() * 0.85);
		validationSetEnd = packets.size() - 1;
	}
}
